package com.liuzh.deviceinfo;

import android.os.Build.VERSION;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.text.SpannableString;
import android.text.method.LinkMovementMethod;
import android.text.style.ForegroundColorSpan;
import android.text.style.UnderlineSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.appcompat.app.AlertController;
import b.b.c.f;
import c.h.a.f0.j;
import c.h.a.g;
import c.h.a.i;
import c.h.a.k;
import c.h.a.l;
import c.h.a.m;
import c.h.a.m0.h;
import c.h.a.r;
import c.h.a.s;
import c.h.b.a.a.b;
import c.h.b.a.a.c;
import com.huawei.agconnect.exception.AGCServerException;
import com.liuzh.deviceinfo.base.BaseActivity;
import com.liuzh.deviceinfo.view.StarAnimView;
import java.util.Random;

public class SplashActivity extends BaseActivity {
    public StarAnimView q;
    public final Handler r = new Handler(Looper.getMainLooper());
    public FrameLayout s;

    public class a extends b {
        public final /* synthetic */ long a;

        public a(long j) {
            this.a = j;
        }

        public void b() {
            c.f.a.a.a.a.z("ad_splash");
        }

        public void d(String str) {
            c.f.a.a.a.a.x("ad_splash", str);
            i();
        }

        public void e(View view) {
            SplashActivity.this.r.removeCallbacksAndMessages(null);
            ViewGroup viewGroup = (ViewGroup) SplashActivity.this.findViewById(2131296331);
            viewGroup.removeAllViews();
            viewGroup.addView(view);
        }

        public void g() {
            i();
        }

        public void h() {
            i();
        }

        public final void i() {
            SplashActivity.this.r.removeCallbacksAndMessages(null);
            if (!h.q(SplashActivity.this)) {
                long currentTimeMillis = System.currentTimeMillis() - this.a;
                if (currentTimeMillis < 500) {
                    SplashActivity.this.A(500 - currentTimeMillis);
                } else {
                    SplashActivity.this.A(0);
                }
            }
        }
    }

    public final void A(long j) {
        c.h.a.m0.p.a.a.postDelayed(new i(this), j);
    }

    public final void B() {
        long currentTimeMillis = System.currentTimeMillis();
        c.f.a.a.a.a.y("ad_splash");
        c.a(this, c.h.a.u.a.f, new a(currentTimeMillis));
        this.r.postDelayed(new m(this), 3000);
    }

    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        c.h.a.m0.i iVar = c.h.a.m0.i.a;
        iVar = c.h.a.m0.i.a;
        if (c.h.a.m0.i.b.getBoolean("agree_privacy_policy", false)) {
            setContentView(2131492900);
            ImageView imageView = (ImageView) findViewById(2131296648);
            int i = VERSION.SDK_INT;
            imageView.setImageResource(h.b(i));
            ((TextView) findViewById(2131296349)).setText(h.c(i));
            if (j.d.i() || c.h.a.m0.i.b()) {
                A((long) (new Random().nextInt(AGCServerException.OK) + 300));
                return;
            } else {
                B();
                return;
            }
        }
        setContentView(2131492899);
        this.s = (FrameLayout) findViewById(2131296398);
        this.q = (StarAnimView) findViewById(2131296994);
        if (h.r()) {
            LayoutInflater.from(this).inflate(2131493046, this.s, true);
            SpannableString spannableString = new SpannableString("感谢您安装使用《设备信息》应用，我们将严格遵守相关法律法规收集使用您的个人信息。\n未经您授权，我们不会收集、使用和共享您的个人信息。在开始使用前，请您充分阅读并理解《隐私协议》。");
            spannableString.setSpan(new r(this), 82, 88, 18);
            spannableString.setSpan(new ForegroundColorSpan(-16776961), 82, 88, 18);
            b.b.c.f.a aVar = new b.b.c.f.a(this);
            AlertController.b bVar = aVar.a;
            bVar.d = "隐私保护";
            bVar.f = spannableString;
            c.h.a.h hVar = new c.h.a.h(this);
            bVar.i = "不同意";
            bVar.j = hVar;
            l lVar = new l(this);
            bVar.g = "同意并继续";
            bVar.h = lVar;
            bVar.m = false;
            f a = aVar.a();
            a.setOnShowListener(new k(this, a));
            a.show();
            return;
        }
        LayoutInflater.from(this).inflate(2131493045, this.s, true);
        TextView textView = (TextView) findViewById(2131296338);
        textView.setMovementMethod(LinkMovementMethod.getInstance());
        textView.setHighlightColor(866822826);
        String string = getString(2131690188);
        String string2 = getString(2131690398, new Object[]{string});
        try {
            SpannableString spannableString2 = new SpannableString(string2);
            int indexOf = string2.indexOf(string);
            int length = string.length() + indexOf;
            spannableString2.setSpan(new ForegroundColorSpan(c.f.a.a.a.a.n(this, 16842907)), indexOf, length, 18);
            spannableString2.setSpan(new UnderlineSpan(), indexOf, length, 18);
            spannableString2.setSpan(new s(this), indexOf, length, 18);
            textView.setText(spannableString2);
        } catch (Exception unused) {
            textView.setText(string2);
        }
        Button button = (Button) findViewById(2131296413);
        button.setOnClickListener(new g(this, button));
    }

    public int x(boolean z) {
        return z ? 2131755020 : 2131755022;
    }

    public boolean y() {
        return false;
    }
}
